//
//  OAuth2ViewController.m
//  SinaWebo
//
//  Created by wwj on 16/7/4.
//  Copyright © 2016年 亦心. All rights reserved.
//

#import "OAuth2ViewController.h"
#import "Account.h"
#import "TabBarViewController.h"
#import "NewFeatureViewController.h"
#import "ChooseControllerUtil.h"
#import "UserPerfenceUtil.h"
#import "HttpUtil.h"
#import "OAuthService.h"

@interface OAuth2ViewController ()
@property (weak, nonatomic) IBOutlet UITextField *userTF;
@property (weak, nonatomic) IBOutlet UITextField *passTF;

@end

@implementation OAuth2ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
}


- (IBAction)onClickLogin:(UIButton *)sender {
    [self userLogin];
}

- (void)userLogin{
    LoginRequest *request = [[LoginRequest alloc] init];
    request.p = @"I5yJWqLeFfwCDARqeBDRHlNwPLdoxxT/AHUwZBl9W91SGlcQ+drlIp9EYh+D5fNADokAmi7ZinCZTXc7Ml4VoX3UXdyWFJ5O9F86/r1sO1QEQJRh6jMIM+w9l7bgJAOlwlcHwVGlnYGtG7fPSVMpyoReJGpgXByVJKoPmspAaY8=";
    request.luicode = @"10000229";
    request.uicode = @"10000058";
    request.s = @"48b0583b";
    request.flag = @"1";
    request.imei = @"64fed9580e117875ce3ecff976e0e1adbc2e44c1";
    request.device_name = @"“亦心”的 iPhone7";
    request.getcookie = @"1";
    request.u = self.userTF.text;
    request.device_id = @"5a7bfd9655ce8eaafc19c56e119281123f2b02da";
    request.moduleID = @"account";
    [OAuthService getLoginDataWithRequest:request success:^(LoginResponse *response) {
        Account *account= [[Account alloc] init];
        account.gsid = response.gsid;
        account.screen_name = response.screen_name;
        account.uid = response.uid;
        account.oauth_token = response.oauth_token;
        account.oauth_token_secret = response.oauth_token_secret;
        account.malt = response.malt;
        account.user = response.user;
        //存档
        [UserPerfenceUtil saveAccount:account];
        
        //设置要要跳转的控制器
        [ChooseControllerUtil chooseRootController];
    } failure:nil];
}


@end
